import java.util.ArrayList;
import java.util.Random;

/**
 * @ClassName Member
 * @Description 定义成员类
 * @Author Li
 * @Date 2022/8/1 14:22
 * @ModifyDate 2022/8/1 14:22
 * @Version 1.0
 */
public class Member extends User {
    public Member() {
    }

    public Member(String name, int money) {
        super(name, money);
    }

    // 收红包
    public void receive(ArrayList<Integer> list) {
        // 创建一个随机数值
        int index = new Random().nextInt(list.size());
        // 获取成员余额
        int balance = super.getMoney();
        // 从红包拿出一份
        int money = list.remove(index);
        // 将红包金额加到余额中
        super.setMoney(balance + money);
    }
}
